package ltd.dujiabao.performance.monitor.pm.publisher.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Component;

import ltd.dujiabao.performance.monitor.pm.event.CollectEvent;
import ltd.dujiabao.performance.monitor.pm.publisher.CollectPublisher;

/**
 * @author : DuJiabao
 * @Project : performance_monitor
 * @Time : 2022/2/27 21:10
 * @Desc :
 */
@Component
public class LocalPublisher implements CollectPublisher {
    private final ApplicationContext applicationContext;

    @Autowired
    public LocalPublisher(ApplicationContext applicationContext) {
        this.applicationContext = applicationContext;
    }

    @Override
    public void publish(long timeConsuming, String[] urls) {
        CollectEvent collectEvent = new CollectEvent(this, timeConsuming, urls);
        applicationContext.publishEvent(collectEvent);
    }
}
